package com.example.web;

import com.example.daoman.*;
import com.example.mapper.FloorMapper;
import com.example.service.impl.*;
import com.example.utils.GetSession;
import com.example.utils.Message;
import org.apache.poi.util.Removal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;
import java.util.List;

//管理员接口设计
@RequestMapping("/root")
@RestController
public class RootInterFace {

    @Autowired
    private RoomServiceImpl roomService;

    @Autowired
    private FloorServiceImpl floorService;

    @Autowired
    private UserServiceImpl userService;

    @Autowired
    private RepairServiceImpl repairService;

    @Autowired
    private NoticeServiceImpl noticeService;

    @Autowired
    private AssessServiceImpl assessService;

    @Autowired
    private TradeServiceImpl tradeService;

    //    管理员同意换寝室
    @RequestMapping("/setAssess")
    public Message set(@RequestBody Trade trade) {
        return tradeService.setAssess(trade);
    }

    //    管理员删除换寝室申请
    @RequestMapping("/cancel")
    public Message removeAssess(@RequestBody Trade trade) {
        return tradeService.removeAssess(trade);
    }


    //    管理员查询所有的换寝室申请记录消息
    @RequestMapping("/allAssess")
    public Message getRootChane(@RequestBody List<Floor> floorList) {
        return tradeService.getMyAllFloorAssess(floorList);
    }

    //    管理员添加考核记录
    @RequestMapping("/addAssess")
    public Message addAssess(@RequestBody Assess assess) {
        return assessService.addAssess(assess);
    }

//    管理员添加考核记录


    //    删除学员的考核记录
    @RequestMapping("/removeAssess/{id}")
    public Message removeAssess(@PathVariable int id) {
        return assessService.removeAssess(id);
    }

    //  查询所哟的考核记录
    @RequestMapping("/assessAll")
    public Message getAllAssess(@RequestBody List<Floor> floorList) {
        return assessService.getAllAssessList(floorList);
    }

    //    管理员考核查询管理的所哟的学员信息
    @RequestMapping("/userAll")
    public Message getFloorAllUser(@RequestBody List<Floor> floorList) {
        return userService.getFloorAllUser(floorList);
    }


    //    管理员更新公告
    @RequestMapping("/insertNotice")
    public Message updateNotice(@RequestBody Notice notice) {
        return noticeService.insertNotice(notice);
    }

    //    管理员删除公告
    @RequestMapping("/noticeRemove")
    public Message removeNotice(@RequestBody Notice notice) {
        return noticeService.removeNotice(notice);
    }


    //    管理员根据自己管理的楼成查询对应的房间缴费情况
    @RequestMapping("/apply")
    public Message getRoomApply(@RequestBody List<Floor> floorList) {
        return floorService.getMyFloorApply(floorList);
    }

    //    查询个人信息
    @RequestMapping("/one")
    public Message getOne() {
        return Message.out(200, "查询", GetSession.get());
    }

    //    查询自己所管理的楼层信息
    @RequestMapping("/floor")
    public Message getUserFloor() {
        return floorService.getUserFloorById();
    }

//    根据指定的楼层的id查询对应楼层中的所有的房间 以及每个房间中的每个学院信息

    @RequestMapping("/room/{id}")
    public Message getRoomBedsListByFloorId(@PathVariable("id") int id) {
        return roomService.getRoomBedsListByFloorId(id);
    }

    //    用户管理 查询自己管理的楼层中的所有的用户信息
    @RequestMapping("/user/{page}/{pageSize}")
    public Message getUserAll(@PathVariable int page, @PathVariable int pageSize) {
        return userService.getUserAll(page, pageSize);
    }

    //    根据管理员的楼层查询自己楼层的报修情况
    @RequestMapping("/repair")
    public Message getMyFloorRepair(@RequestBody List<Floor> floorList) {
        return repairService.getMyFloorRepair(floorList);
    }

    //    报修删除操作根据id
    @RequestMapping("/remove")
    public Message remove(@RequestBody Repair repair) {
        return repairService.removeMyFloorRepair(repair);
    }

    //    管理员受理该申请订单
    @RequestMapping("/update")
    public Message updateMyRepair(@RequestBody Repair repair) {
        return repairService.updateMyRepair(repair);
    }

    //    管理员搜索功能 按照姓名搜索
    @RequestMapping("/input")
    public Message input(@RequestBody User user) {
        return userService.inputUserAll(user);
    }

    //    管理员密码重置
    @RequestMapping("/reset")
    public Message resetAll(@RequestBody List<User> userList) {
        return userService.reset(userList);
    }

    //    批量删除所选择的用户
    @RequestMapping("/del")
    public Message del(@RequestBody List<User> userList) {
        return userService.removeUserList(userList);
    }
}
